package com.doit.day01;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class _01_创建名称空间 {
    public static void main(String[] args) throws IOException {
        Configuration conf = HBaseConfiguration.create();
        //设置参数
        conf.set("hbase.zookeeper.quorum","linux01:2181,linux02:2181,linux03:2181");
        //创建连接对象
        Connection conn = ConnectionFactory.createConnection(conf);
        //获取连接对象
        Admin admin = conn.getAdmin();

        //创建了一个名称空间描述器的构造器
        NamespaceDescriptor.Builder java = NamespaceDescriptor.create("java");
        //创建一个hashmap，类型是String，String
        HashMap<String, String> map = new HashMap<>();
        map.put("desc","from java");
        map.put("author","robot_jiang");
        map.put("time","2023-08-12");
        java.addConfiguration(map);
//        java.addConfiguration("desc","from java");
        //用构造器构造名称空间的描述器
        NamespaceDescriptor build = java.build();
        //创建一个名称空间
        admin.createNamespace(build);



    }
}
